package com.bupt.config.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfigurer implements WebMvcConfigurer {

        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(new AccessLimitInterceptor())
                    .addPathPatterns("/**")
                    .excludePathPatterns("/swagger-ui.html")
                    .excludePathPatterns("/configuration/ui")
                    .excludePathPatterns("/swagger-resources")
                    .excludePathPatterns("/configuration/security")
                    .excludePathPatterns("/v2/api-docs")
                    .excludePathPatterns("/error")
                    .excludePathPatterns("/webjars/**")
                    .excludePathPatterns("/**/favicon.ico")
                    .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
        }
    }

